// $ANTLR 3.1.3 Mar 18, 2009 10:09:25 YaplTree.g 2011-04-26 20:05:25


	using YAPL.Language.Ast;
	using System.Collections.Generic;
	using System.Diagnostics;
	using System.Globalization;
	using YAPL.Language.SourceParser.Helpers;


using System;
using Antlr.Runtime;
using Antlr.Runtime.Tree;using IList 		= System.Collections.IList;
using ArrayList 	= System.Collections.ArrayList;
using Stack 		= Antlr.Runtime.Collections.StackList;


namespace  YAPL.Language.SourceParser.Antlr 
{
public class YaplTree : TreeParser 
{
    public static readonly string[] tokenNames = new string[] 
	{
        "<invalid>", 
		"<EOR>", 
		"<DOWN>", 
		"<UP>", 
		"ASSIGN", 
		"LEFT_PAREN", 
		"RIGHT_PAREN", 
		"LEFT_BRACE", 
		"RIGHT_BRACE", 
		"FUNC", 
		"END", 
		"RET", 
		"CLASS", 
		"WHILE", 
		"IF", 
		"ELSE", 
		"TRUE_C", 
		"FALSE_C", 
		"COMMA", 
		"DOT", 
		"DECREMENT", 
		"INCREMENT", 
		"MINUS", 
		"PLUS", 
		"MULTIPLY", 
		"DIVIDE", 
		"MOD", 
		"AND", 
		"OR", 
		"NOT", 
		"INTEGER", 
		"FLOAT", 
		"BOOL_C", 
		"UPPER", 
		"LETTER", 
		"DIGIT", 
		"CLASS_NAME", 
		"NAME", 
		"DOLLAR", 
		"INSTANCE_NAME", 
		"NONCONTROL_CHAR", 
		"STRING_LITERAL", 
		"SYMBOL", 
		"SPACE", 
		"LOWER", 
		"WHITESPACE", 
		"NEWLINE", 
		"CODE_BLOCK", 
		"STRING_CONSTANT", 
		"INT_CONSTANT", 
		"FLOAT_CONSTANT", 
		"BOOL_CONSTANT", 
		"EXPR_FUNC_CALL", 
		"CLASS_FUNC_CALL", 
		"INSTVAR_FUNC_CALL", 
		"CLASS_REFERENCE", 
		"CLASS_DEF", 
		"FUNC_CALL", 
		"FUNC_DEF", 
		"VAR_FUNC_DEF", 
		"CR_FUNC_DEF", 
		"INSTVAR_FUNC_DEF", 
		"RETURN", 
		"EXPR_LIST", 
		"PARAM_LIST", 
		"PARAM", 
		"VARIABLE", 
		"INSTANCE_VARIABLE", 
		"ASSIGNMENT", 
		"UNARY", 
		"WHILE_ST", 
		"IF_ST"
    };

    public const int DOLLAR = 38;
    public const int CLASS = 12;
    public const int WHILE = 13;
    public const int MOD = 26;
    public const int LETTER = 34;
    public const int INSTANCE_NAME = 39;
    public const int PARAM = 65;
    public const int FLOAT = 31;
    public const int NOT = 29;
    public const int AND = 27;
    public const int SPACE = 43;
    public const int EOF = -1;
    public const int CLASS_REFERENCE = 55;
    public const int FALSE_C = 17;
    public const int IF = 14;
    public const int FUNC_CALL = 57;
    public const int EXPR_LIST = 63;
    public const int RIGHT_PAREN = 6;
    public const int RET = 11;
    public const int NAME = 37;
    public const int STRING_LITERAL = 41;
    public const int BOOL_CONSTANT = 51;
    public const int MULTIPLY = 24;
    public const int COMMA = 18;
    public const int RETURN = 62;
    public const int PLUS = 23;
    public const int DIGIT = 35;
    public const int UNARY = 69;
    public const int DOT = 19;
    public const int DIVIDE = 25;
    public const int RIGHT_BRACE = 8;
    public const int INTEGER = 30;
    public const int INT_CONSTANT = 49;
    public const int BOOL_C = 32;
    public const int INSTVAR_FUNC_CALL = 54;
    public const int WHILE_ST = 70;
    public const int FLOAT_CONSTANT = 50;
    public const int CLASS_NAME = 36;
    public const int SYMBOL = 42;
    public const int ELSE = 15;
    public const int WHITESPACE = 45;
    public const int FUNC_DEF = 58;
    public const int MINUS = 22;
    public const int STRING_CONSTANT = 48;
    public const int DECREMENT = 20;
    public const int EXPR_FUNC_CALL = 52;
    public const int IF_ST = 71;
    public const int INCREMENT = 21;
    public const int PARAM_LIST = 64;
    public const int NEWLINE = 46;
    public const int VARIABLE = 66;
    public const int NONCONTROL_CHAR = 40;
    public const int LEFT_BRACE = 7;
    public const int FUNC = 9;
    public const int CR_FUNC_DEF = 60;
    public const int INSTANCE_VARIABLE = 67;
    public const int OR = 28;
    public const int ASSIGN = 4;
    public const int CODE_BLOCK = 47;
    public const int VAR_FUNC_DEF = 59;
    public const int LEFT_PAREN = 5;
    public const int TRUE_C = 16;
    public const int ASSIGNMENT = 68;
    public const int LOWER = 44;
    public const int END = 10;
    public const int INSTVAR_FUNC_DEF = 61;
    public const int CLASS_DEF = 56;
    public const int UPPER = 33;
    public const int CLASS_FUNC_CALL = 53;

    // delegates
    // delegators



        public YaplTree(ITreeNodeStream input)
    		: this(input, new RecognizerSharedState()) {
        }

        public YaplTree(ITreeNodeStream input, RecognizerSharedState state)
    		: base(input, state) {
            InitializeCyclicDFAs();

             
       }
        

    override public string[] TokenNames {
		get { return YaplTree.tokenNames; }
    }

    override public string GrammarFileName {
		get { return "YaplTree.g"; }
    }



    // $ANTLR start "prog"
    // YaplTree.g:19:1: prog returns [ProgramDefExpression result] : (c= code_block ) ;
    public ProgramDefExpression prog() // throws RecognitionException [1]
    {   
        ProgramDefExpression result = null;

        CodeBlockExpression c = null;


        try 
    	{
            // YaplTree.g:20:2: ( (c= code_block ) )
            // YaplTree.g:20:4: (c= code_block )
            {
            	// YaplTree.g:20:4: (c= code_block )
            	// YaplTree.g:20:5: c= code_block
            	{
            		PushFollow(FOLLOW_code_block_in_prog61);
            		c = code_block();
            		state.followingStackPointer--;


            	}

            	 result =  Expressions.Program(c); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "prog"


    // $ANTLR start "function"
    // YaplTree.g:24:1: function returns [FunctionDefExpression result] : ( ^( FUNC_DEF fname= NAME plist= param_list code= code_block ) | ^( VAR_FUNC_DEF fname= NAME plist= param_list code= code_block v= variable ) | ^( CR_FUNC_DEF fname= NAME plist= param_list code= code_block cr= class_reference ) | ^( INSTVAR_FUNC_DEF fname= NAME plist= param_list code= code_block instv= instance_variable ) );
    public FunctionDefExpression function() // throws RecognitionException [1]
    {   
        FunctionDefExpression result = null;

        CommonTree fname = null;
        List<ParameterExpression> plist = null;

        CodeBlockExpression code = null;

        VariableExpression v = null;

        ClassReferenceExpression cr = null;

        InstanceVariableExpression instv = null;


        try 
    	{
            // YaplTree.g:25:2: ( ^( FUNC_DEF fname= NAME plist= param_list code= code_block ) | ^( VAR_FUNC_DEF fname= NAME plist= param_list code= code_block v= variable ) | ^( CR_FUNC_DEF fname= NAME plist= param_list code= code_block cr= class_reference ) | ^( INSTVAR_FUNC_DEF fname= NAME plist= param_list code= code_block instv= instance_variable ) )
            int alt1 = 4;
            switch ( input.LA(1) ) 
            {
            case FUNC_DEF:
            	{
                alt1 = 1;
                }
                break;
            case VAR_FUNC_DEF:
            	{
                alt1 = 2;
                }
                break;
            case CR_FUNC_DEF:
            	{
                alt1 = 3;
                }
                break;
            case INSTVAR_FUNC_DEF:
            	{
                alt1 = 4;
                }
                break;
            	default:
            	    NoViableAltException nvae_d1s0 =
            	        new NoViableAltException("", 1, 0, input);

            	    throw nvae_d1s0;
            }

            switch (alt1) 
            {
                case 1 :
                    // YaplTree.g:25:4: ^( FUNC_DEF fname= NAME plist= param_list code= code_block )
                    {
                    	Match(input,FUNC_DEF,FOLLOW_FUNC_DEF_in_function81); 

                    	Match(input, Token.DOWN, null); 
                    	fname=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_function85); 
                    	PushFollow(FOLLOW_param_list_in_function89);
                    	plist = param_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_code_block_in_function93);
                    	code = code_block();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.Function(fname.Text, plist, code); 

                    }
                    break;
                case 2 :
                    // YaplTree.g:26:4: ^( VAR_FUNC_DEF fname= NAME plist= param_list code= code_block v= variable )
                    {
                    	Match(input,VAR_FUNC_DEF,FOLLOW_VAR_FUNC_DEF_in_function102); 

                    	Match(input, Token.DOWN, null); 
                    	fname=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_function106); 
                    	PushFollow(FOLLOW_param_list_in_function110);
                    	plist = param_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_code_block_in_function114);
                    	code = code_block();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_variable_in_function118);
                    	v = variable();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.Function(fname.Text, v, plist, code); 

                    }
                    break;
                case 3 :
                    // YaplTree.g:27:4: ^( CR_FUNC_DEF fname= NAME plist= param_list code= code_block cr= class_reference )
                    {
                    	Match(input,CR_FUNC_DEF,FOLLOW_CR_FUNC_DEF_in_function127); 

                    	Match(input, Token.DOWN, null); 
                    	fname=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_function131); 
                    	PushFollow(FOLLOW_param_list_in_function135);
                    	plist = param_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_code_block_in_function139);
                    	code = code_block();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_class_reference_in_function143);
                    	cr = class_reference();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.Function(fname.Text, cr, plist, code); 

                    }
                    break;
                case 4 :
                    // YaplTree.g:28:4: ^( INSTVAR_FUNC_DEF fname= NAME plist= param_list code= code_block instv= instance_variable )
                    {
                    	Match(input,INSTVAR_FUNC_DEF,FOLLOW_INSTVAR_FUNC_DEF_in_function152); 

                    	Match(input, Token.DOWN, null); 
                    	fname=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_function156); 
                    	PushFollow(FOLLOW_param_list_in_function160);
                    	plist = param_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_code_block_in_function164);
                    	code = code_block();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_instance_variable_in_function168);
                    	instv = instance_variable();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.Function(fname.Text, instv, plist, code); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "function"


    // $ANTLR start "while_loop"
    // YaplTree.g:31:1: while_loop returns [WhileExpression result] : ^( WHILE_ST expr= expression code= code_block ) ;
    public WhileExpression while_loop() // throws RecognitionException [1]
    {   
        WhileExpression result = null;

        Expression expr = null;

        CodeBlockExpression code = null;


        try 
    	{
            // YaplTree.g:32:2: ( ^( WHILE_ST expr= expression code= code_block ) )
            // YaplTree.g:32:4: ^( WHILE_ST expr= expression code= code_block )
            {
            	Match(input,WHILE_ST,FOLLOW_WHILE_ST_in_while_loop187); 

            	Match(input, Token.DOWN, null); 
            	PushFollow(FOLLOW_expression_in_while_loop191);
            	expr = expression();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_code_block_in_while_loop195);
            	code = code_block();
            	state.followingStackPointer--;


            	Match(input, Token.UP, null); 
            	 result =  Expressions.While(expr, code); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "while_loop"


    // $ANTLR start "if_statement"
    // YaplTree.g:36:1: if_statement returns [ConditionalExpression result] : ^( IF_ST expr= expression th= code_block el= code_block ) ;
    public ConditionalExpression if_statement() // throws RecognitionException [1]
    {   
        ConditionalExpression result = null;

        Expression expr = null;

        CodeBlockExpression th = null;

        CodeBlockExpression el = null;


        try 
    	{
            // YaplTree.g:37:2: ( ^( IF_ST expr= expression th= code_block el= code_block ) )
            // YaplTree.g:37:4: ^( IF_ST expr= expression th= code_block el= code_block )
            {
            	Match(input,IF_ST,FOLLOW_IF_ST_in_if_statement215); 

            	Match(input, Token.DOWN, null); 
            	PushFollow(FOLLOW_expression_in_if_statement219);
            	expr = expression();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_code_block_in_if_statement223);
            	th = code_block();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_code_block_in_if_statement227);
            	el = code_block();
            	state.followingStackPointer--;


            	Match(input, Token.UP, null); 
            	 result =  Expressions.Conditional(expr, th, el); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "if_statement"


    // $ANTLR start "class_def"
    // YaplTree.g:40:1: class_def returns [ClassDefExpression result] : ^( CLASS_DEF cname= CLASS_NAME code= code_block ) ;
    public ClassDefExpression class_def() // throws RecognitionException [1]
    {   
        ClassDefExpression result = null;

        CommonTree cname = null;
        CodeBlockExpression code = null;


        try 
    	{
            // YaplTree.g:41:2: ( ^( CLASS_DEF cname= CLASS_NAME code= code_block ) )
            // YaplTree.g:41:4: ^( CLASS_DEF cname= CLASS_NAME code= code_block )
            {
            	Match(input,CLASS_DEF,FOLLOW_CLASS_DEF_in_class_def246); 

            	Match(input, Token.DOWN, null); 
            	cname=(CommonTree)Match(input,CLASS_NAME,FOLLOW_CLASS_NAME_in_class_def250); 
            	PushFollow(FOLLOW_code_block_in_class_def254);
            	code = code_block();
            	state.followingStackPointer--;


            	Match(input, Token.UP, null); 
            	 result =  Expressions.ClassDef(cname.Text, code); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "class_def"


    // $ANTLR start "param_list"
    // YaplTree.g:45:1: param_list returns [List<ParameterExpression> list] : ^( PARAM_LIST (v= param )* ) ;
    public List<ParameterExpression> param_list() // throws RecognitionException [1]
    {   
        List<ParameterExpression> list = null;

        ParameterExpression v = null;


         list = new List<ParameterExpression>(); 
        try 
    	{
            // YaplTree.g:47:2: ( ^( PARAM_LIST (v= param )* ) )
            // YaplTree.g:47:4: ^( PARAM_LIST (v= param )* )
            {
            	Match(input,PARAM_LIST,FOLLOW_PARAM_LIST_in_param_list280); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // YaplTree.g:47:17: (v= param )*
            	    do 
            	    {
            	        int alt2 = 2;
            	        int LA2_0 = input.LA(1);

            	        if ( (LA2_0 == PARAM) )
            	        {
            	            alt2 = 1;
            	        }


            	        switch (alt2) 
            	    	{
            	    		case 1 :
            	    		    // YaplTree.g:47:18: v= param
            	    		    {
            	    		    	PushFollow(FOLLOW_param_in_param_list285);
            	    		    	v = param();
            	    		    	state.followingStackPointer--;

            	    		    	 list.Add(v); 

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop2;
            	        }
            	    } while (true);

            	    loop2:
            	    	;	// Stops C# compiler whining that label 'loop2' has no statements


            	    Match(input, Token.UP, null); 
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return list;
    }
    // $ANTLR end "param_list"


    // $ANTLR start "param"
    // YaplTree.g:50:1: param returns [ParameterExpression result] : ^( PARAM n= NAME ) ;
    public ParameterExpression param() // throws RecognitionException [1]
    {   
        ParameterExpression result = null;

        CommonTree n = null;

        try 
    	{
            // YaplTree.g:51:2: ( ^( PARAM n= NAME ) )
            // YaplTree.g:51:4: ^( PARAM n= NAME )
            {
            	Match(input,PARAM,FOLLOW_PARAM_in_param306); 

            	Match(input, Token.DOWN, null); 
            	n=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_param310); 

            	Match(input, Token.UP, null); 
            	 result =  Expressions.Parameter(Expressions.Variable(n.Text),Expressions.Undefined()); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "param"


    // $ANTLR start "code_block"
    // YaplTree.g:53:1: code_block returns [CodeBlockExpression result] : ^( CODE_BLOCK (v= statement )* ) ;
    public CodeBlockExpression code_block() // throws RecognitionException [1]
    {   
        CodeBlockExpression result = null;

        Expression v = null;


         var exprs = new List<Expression>(); 
        try 
    	{
            // YaplTree.g:56:2: ( ^( CODE_BLOCK (v= statement )* ) )
            // YaplTree.g:56:4: ^( CODE_BLOCK (v= statement )* )
            {
            	Match(input,CODE_BLOCK,FOLLOW_CODE_BLOCK_in_code_block340); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // YaplTree.g:56:17: (v= statement )*
            	    do 
            	    {
            	        int alt3 = 2;
            	        int LA3_0 = input.LA(1);

            	        if ( ((LA3_0 >= MINUS && LA3_0 <= OR) || (LA3_0 >= STRING_CONSTANT && LA3_0 <= INSTVAR_FUNC_CALL) || (LA3_0 >= CLASS_DEF && LA3_0 <= RETURN) || (LA3_0 >= VARIABLE && LA3_0 <= IF_ST)) )
            	        {
            	            alt3 = 1;
            	        }


            	        switch (alt3) 
            	    	{
            	    		case 1 :
            	    		    // YaplTree.g:56:18: v= statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_code_block345);
            	    		    	v = statement();
            	    		    	state.followingStackPointer--;

            	    		    	exprs.Add(v); 

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop3;
            	        }
            	    } while (true);

            	    loop3:
            	    	;	// Stops C# compiler whining that label 'loop3' has no statements


            	    Match(input, Token.UP, null); 
            	}

            }

             result =  Expressions.CodeBlock(exprs); 
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "code_block"


    // $ANTLR start "statement"
    // YaplTree.g:59:1: statement returns [Expression result] : ( (ret= return_stmt ) | (expr= expression ) | (a= assignment ) | (f= function ) | (w= while_loop ) | (i= if_statement ) | (c= class_def ) );
    public Expression statement() // throws RecognitionException [1]
    {   
        Expression result = null;

        ReturnExpression ret = null;

        Expression expr = null;

        AssignmentExpression a = null;

        FunctionDefExpression f = null;

        WhileExpression w = null;

        ConditionalExpression i = null;

        ClassDefExpression c = null;


        try 
    	{
            // YaplTree.g:60:2: ( (ret= return_stmt ) | (expr= expression ) | (a= assignment ) | (f= function ) | (w= while_loop ) | (i= if_statement ) | (c= class_def ) )
            int alt4 = 7;
            switch ( input.LA(1) ) 
            {
            case RETURN:
            	{
                alt4 = 1;
                }
                break;
            case MINUS:
            case PLUS:
            case MULTIPLY:
            case DIVIDE:
            case MOD:
            case AND:
            case OR:
            case STRING_CONSTANT:
            case INT_CONSTANT:
            case FLOAT_CONSTANT:
            case BOOL_CONSTANT:
            case EXPR_FUNC_CALL:
            case CLASS_FUNC_CALL:
            case INSTVAR_FUNC_CALL:
            case FUNC_CALL:
            case VARIABLE:
            case INSTANCE_VARIABLE:
            case UNARY:
            	{
                alt4 = 2;
                }
                break;
            case ASSIGNMENT:
            	{
                alt4 = 3;
                }
                break;
            case FUNC_DEF:
            case VAR_FUNC_DEF:
            case CR_FUNC_DEF:
            case INSTVAR_FUNC_DEF:
            	{
                alt4 = 4;
                }
                break;
            case WHILE_ST:
            	{
                alt4 = 5;
                }
                break;
            case IF_ST:
            	{
                alt4 = 6;
                }
                break;
            case CLASS_DEF:
            	{
                alt4 = 7;
                }
                break;
            	default:
            	    NoViableAltException nvae_d4s0 =
            	        new NoViableAltException("", 4, 0, input);

            	    throw nvae_d4s0;
            }

            switch (alt4) 
            {
                case 1 :
                    // YaplTree.g:60:3: (ret= return_stmt )
                    {
                    	// YaplTree.g:60:3: (ret= return_stmt )
                    	// YaplTree.g:60:4: ret= return_stmt
                    	{
                    		PushFollow(FOLLOW_return_stmt_in_statement368);
                    		ret = return_stmt();
                    		state.followingStackPointer--;


                    	}


                    			result =  ret;

                    }
                    break;
                case 2 :
                    // YaplTree.g:63:2: (expr= expression )
                    {
                    	// YaplTree.g:63:2: (expr= expression )
                    	// YaplTree.g:63:3: expr= expression
                    	{
                    		PushFollow(FOLLOW_expression_in_statement382);
                    		expr = expression();
                    		state.followingStackPointer--;


                    	}


                    			result =  expr;

                    }
                    break;
                case 3 :
                    // YaplTree.g:66:2: (a= assignment )
                    {
                    	// YaplTree.g:66:2: (a= assignment )
                    	// YaplTree.g:66:3: a= assignment
                    	{
                    		PushFollow(FOLLOW_assignment_in_statement396);
                    		a = assignment();
                    		state.followingStackPointer--;


                    	}


                    			result =  a;

                    }
                    break;
                case 4 :
                    // YaplTree.g:69:2: (f= function )
                    {
                    	// YaplTree.g:69:2: (f= function )
                    	// YaplTree.g:69:3: f= function
                    	{
                    		PushFollow(FOLLOW_function_in_statement410);
                    		f = function();
                    		state.followingStackPointer--;


                    	}


                    			result =  f;

                    }
                    break;
                case 5 :
                    // YaplTree.g:72:2: (w= while_loop )
                    {
                    	// YaplTree.g:72:2: (w= while_loop )
                    	// YaplTree.g:72:3: w= while_loop
                    	{
                    		PushFollow(FOLLOW_while_loop_in_statement424);
                    		w = while_loop();
                    		state.followingStackPointer--;


                    	}


                    			result =  w;

                    }
                    break;
                case 6 :
                    // YaplTree.g:75:2: (i= if_statement )
                    {
                    	// YaplTree.g:75:2: (i= if_statement )
                    	// YaplTree.g:75:3: i= if_statement
                    	{
                    		PushFollow(FOLLOW_if_statement_in_statement438);
                    		i = if_statement();
                    		state.followingStackPointer--;


                    	}


                    			result =  i;

                    }
                    break;
                case 7 :
                    // YaplTree.g:78:2: (c= class_def )
                    {
                    	// YaplTree.g:78:2: (c= class_def )
                    	// YaplTree.g:78:3: c= class_def
                    	{
                    		PushFollow(FOLLOW_class_def_in_statement452);
                    		c = class_def();
                    		state.followingStackPointer--;


                    	}


                    			result =  c;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "statement"


    // $ANTLR start "expression"
    // YaplTree.g:82:1: expression returns [Expression result] : ( ^(op= ( PLUS | MINUS | OR ) left= expression right= expression ) | ^(op= ( MULTIPLY | DIVIDE | MOD | AND ) left= expression right= expression ) | ^( UNARY u= unary_operator e= expression ) | (v= variable ) | (i= instance_variable ) | (fn= func_call ) | (c= constant ) );
    public Expression expression() // throws RecognitionException [1]
    {   
        Expression result = null;

        CommonTree op = null;
        Expression left = null;

        Expression right = null;

        string u = null;

        Expression e = null;

        VariableExpression v = null;

        InstanceVariableExpression i = null;

        Expression fn = null;

        ConstantExpression c = null;


        try 
    	{
            // YaplTree.g:83:2: ( ^(op= ( PLUS | MINUS | OR ) left= expression right= expression ) | ^(op= ( MULTIPLY | DIVIDE | MOD | AND ) left= expression right= expression ) | ^( UNARY u= unary_operator e= expression ) | (v= variable ) | (i= instance_variable ) | (fn= func_call ) | (c= constant ) )
            int alt5 = 7;
            switch ( input.LA(1) ) 
            {
            case MINUS:
            case PLUS:
            case OR:
            	{
                alt5 = 1;
                }
                break;
            case MULTIPLY:
            case DIVIDE:
            case MOD:
            case AND:
            	{
                alt5 = 2;
                }
                break;
            case UNARY:
            	{
                alt5 = 3;
                }
                break;
            case VARIABLE:
            	{
                alt5 = 4;
                }
                break;
            case INSTANCE_VARIABLE:
            	{
                alt5 = 5;
                }
                break;
            case EXPR_FUNC_CALL:
            case CLASS_FUNC_CALL:
            case INSTVAR_FUNC_CALL:
            case FUNC_CALL:
            	{
                alt5 = 6;
                }
                break;
            case STRING_CONSTANT:
            case INT_CONSTANT:
            case FLOAT_CONSTANT:
            case BOOL_CONSTANT:
            	{
                alt5 = 7;
                }
                break;
            	default:
            	    NoViableAltException nvae_d5s0 =
            	        new NoViableAltException("", 5, 0, input);

            	    throw nvae_d5s0;
            }

            switch (alt5) 
            {
                case 1 :
                    // YaplTree.g:83:4: ^(op= ( PLUS | MINUS | OR ) left= expression right= expression )
                    {
                    	op = (CommonTree)input.LT(1);
                    	if ( (input.LA(1) >= MINUS && input.LA(1) <= PLUS) || input.LA(1) == OR ) 
                    	{
                    	    input.Consume();
                    	    state.errorRecovery = false;
                    	}
                    	else 
                    	{
                    	    MismatchedSetException mse = new MismatchedSetException(null,input);
                    	    throw mse;
                    	}


                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_expression_in_expression483);
                    	left = expression();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_expression_in_expression487);
                    	right = expression();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Binary(left,right,OperatorHelper.ParseBinaryOperator(op.Token.Text));

                    }
                    break;
                case 2 :
                    // YaplTree.g:85:4: ^(op= ( MULTIPLY | DIVIDE | MOD | AND ) left= expression right= expression )
                    {
                    	op = (CommonTree)input.LT(1);
                    	if ( (input.LA(1) >= MULTIPLY && input.LA(1) <= AND) ) 
                    	{
                    	    input.Consume();
                    	    state.errorRecovery = false;
                    	}
                    	else 
                    	{
                    	    MismatchedSetException mse = new MismatchedSetException(null,input);
                    	    throw mse;
                    	}


                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_expression_in_expression510);
                    	left = expression();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_expression_in_expression514);
                    	right = expression();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Binary(left,right,OperatorHelper.ParseBinaryOperator(op.Token.Text));

                    }
                    break;
                case 3 :
                    // YaplTree.g:87:4: ^( UNARY u= unary_operator e= expression )
                    {
                    	Match(input,UNARY,FOLLOW_UNARY_in_expression523); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_unary_operator_in_expression527);
                    	u = unary_operator();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_expression_in_expression531);
                    	e = expression();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Unary(e,OperatorHelper.ParseUnaryOperator(u));

                    }
                    break;
                case 4 :
                    // YaplTree.g:89:4: (v= variable )
                    {
                    	// YaplTree.g:89:4: (v= variable )
                    	// YaplTree.g:89:5: v= variable
                    	{
                    		PushFollow(FOLLOW_variable_in_expression541);
                    		v = variable();
                    		state.followingStackPointer--;


                    	}


                    			result =  v;

                    }
                    break;
                case 5 :
                    // YaplTree.g:91:4: (i= instance_variable )
                    {
                    	// YaplTree.g:91:4: (i= instance_variable )
                    	// YaplTree.g:91:5: i= instance_variable
                    	{
                    		PushFollow(FOLLOW_instance_variable_in_expression551);
                    		i = instance_variable();
                    		state.followingStackPointer--;


                    	}


                    			result =  i;

                    }
                    break;
                case 6 :
                    // YaplTree.g:93:4: (fn= func_call )
                    {
                    	// YaplTree.g:93:4: (fn= func_call )
                    	// YaplTree.g:93:5: fn= func_call
                    	{
                    		PushFollow(FOLLOW_func_call_in_expression561);
                    		fn = func_call();
                    		state.followingStackPointer--;


                    	}


                    			result =  fn;

                    }
                    break;
                case 7 :
                    // YaplTree.g:95:4: (c= constant )
                    {
                    	// YaplTree.g:95:4: (c= constant )
                    	// YaplTree.g:95:5: c= constant
                    	{
                    		PushFollow(FOLLOW_constant_in_expression571);
                    		c = constant();
                    		state.followingStackPointer--;


                    	}


                    			result =  c;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "expression"


    // $ANTLR start "assignment"
    // YaplTree.g:99:1: assignment returns [AssignmentExpression result] : ( ^( ASSIGNMENT v= variable e= expression ) | ^( ASSIGNMENT i= instance_variable e= expression ) );
    public AssignmentExpression assignment() // throws RecognitionException [1]
    {   
        AssignmentExpression result = null;

        VariableExpression v = null;

        Expression e = null;

        InstanceVariableExpression i = null;


        try 
    	{
            // YaplTree.g:100:2: ( ^( ASSIGNMENT v= variable e= expression ) | ^( ASSIGNMENT i= instance_variable e= expression ) )
            int alt6 = 2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0 == ASSIGNMENT) )
            {
                int LA6_1 = input.LA(2);

                if ( (LA6_1 == DOWN) )
                {
                    int LA6_2 = input.LA(3);

                    if ( (LA6_2 == VARIABLE) )
                    {
                        alt6 = 1;
                    }
                    else if ( (LA6_2 == INSTANCE_VARIABLE) )
                    {
                        alt6 = 2;
                    }
                    else 
                    {
                        NoViableAltException nvae_d6s2 =
                            new NoViableAltException("", 6, 2, input);

                        throw nvae_d6s2;
                    }
                }
                else 
                {
                    NoViableAltException nvae_d6s1 =
                        new NoViableAltException("", 6, 1, input);

                    throw nvae_d6s1;
                }
            }
            else 
            {
                NoViableAltException nvae_d6s0 =
                    new NoViableAltException("", 6, 0, input);

                throw nvae_d6s0;
            }
            switch (alt6) 
            {
                case 1 :
                    // YaplTree.g:100:4: ^( ASSIGNMENT v= variable e= expression )
                    {
                    	Match(input,ASSIGNMENT,FOLLOW_ASSIGNMENT_in_assignment589); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_variable_in_assignment593);
                    	v = variable();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_expression_in_assignment597);
                    	e = expression();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Assignment(v,e);
                    		

                    }
                    break;
                case 2 :
                    // YaplTree.g:103:4: ^( ASSIGNMENT i= instance_variable e= expression )
                    {
                    	Match(input,ASSIGNMENT,FOLLOW_ASSIGNMENT_in_assignment606); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_instance_variable_in_assignment610);
                    	i = instance_variable();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_expression_in_assignment614);
                    	e = expression();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Assignment(i,e);
                    		

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "assignment"


    // $ANTLR start "unary_operator"
    // YaplTree.g:107:1: unary_operator returns [string result] : ( ( MINUS ) | ( PLUS ) | ( DECREMENT ) | ( INCREMENT ) | ( NOT ) );
    public string unary_operator() // throws RecognitionException [1]
    {   
        string result = null;

        try 
    	{
            // YaplTree.g:108:2: ( ( MINUS ) | ( PLUS ) | ( DECREMENT ) | ( INCREMENT ) | ( NOT ) )
            int alt7 = 5;
            switch ( input.LA(1) ) 
            {
            case MINUS:
            	{
                alt7 = 1;
                }
                break;
            case PLUS:
            	{
                alt7 = 2;
                }
                break;
            case DECREMENT:
            	{
                alt7 = 3;
                }
                break;
            case INCREMENT:
            	{
                alt7 = 4;
                }
                break;
            case NOT:
            	{
                alt7 = 5;
                }
                break;
            	default:
            	    NoViableAltException nvae_d7s0 =
            	        new NoViableAltException("", 7, 0, input);

            	    throw nvae_d7s0;
            }

            switch (alt7) 
            {
                case 1 :
                    // YaplTree.g:108:3: ( MINUS )
                    {
                    	// YaplTree.g:108:3: ( MINUS )
                    	// YaplTree.g:108:4: MINUS
                    	{
                    		Match(input,MINUS,FOLLOW_MINUS_in_unary_operator630); 

                    	}


                    			result = "-";

                    }
                    break;
                case 2 :
                    // YaplTree.g:111:2: ( PLUS )
                    {
                    	// YaplTree.g:111:2: ( PLUS )
                    	// YaplTree.g:111:3: PLUS
                    	{
                    		Match(input,PLUS,FOLLOW_PLUS_in_unary_operator640); 

                    	}


                    			result = "+";

                    }
                    break;
                case 3 :
                    // YaplTree.g:114:2: ( DECREMENT )
                    {
                    	// YaplTree.g:114:2: ( DECREMENT )
                    	// YaplTree.g:114:3: DECREMENT
                    	{
                    		Match(input,DECREMENT,FOLLOW_DECREMENT_in_unary_operator650); 

                    	}


                    			result = "--";

                    }
                    break;
                case 4 :
                    // YaplTree.g:117:2: ( INCREMENT )
                    {
                    	// YaplTree.g:117:2: ( INCREMENT )
                    	// YaplTree.g:117:3: INCREMENT
                    	{
                    		Match(input,INCREMENT,FOLLOW_INCREMENT_in_unary_operator660); 

                    	}


                    			result = "++";

                    }
                    break;
                case 5 :
                    // YaplTree.g:120:2: ( NOT )
                    {
                    	// YaplTree.g:120:2: ( NOT )
                    	// YaplTree.g:120:3: NOT
                    	{
                    		Match(input,NOT,FOLLOW_NOT_in_unary_operator670); 

                    	}


                    			result = "!";

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "unary_operator"


    // $ANTLR start "func_call"
    // YaplTree.g:124:1: func_call returns [Expression result] : ( ^( FUNC_CALL fn= NAME elist= expr_list ) | ^( EXPR_FUNC_CALL fn= NAME elist= expr_list v= variable ) | ^( CLASS_FUNC_CALL fn= NAME elist= expr_list cr= class_reference ) | ^( INSTVAR_FUNC_CALL fn= NAME elist= expr_list inst= instance_variable ) );
    public Expression func_call() // throws RecognitionException [1]
    {   
        Expression result = null;

        CommonTree fn = null;
        List<Expression> elist = null;

        VariableExpression v = null;

        ClassReferenceExpression cr = null;

        InstanceVariableExpression inst = null;


        try 
    	{
            // YaplTree.g:125:2: ( ^( FUNC_CALL fn= NAME elist= expr_list ) | ^( EXPR_FUNC_CALL fn= NAME elist= expr_list v= variable ) | ^( CLASS_FUNC_CALL fn= NAME elist= expr_list cr= class_reference ) | ^( INSTVAR_FUNC_CALL fn= NAME elist= expr_list inst= instance_variable ) )
            int alt8 = 4;
            switch ( input.LA(1) ) 
            {
            case FUNC_CALL:
            	{
                alt8 = 1;
                }
                break;
            case EXPR_FUNC_CALL:
            	{
                alt8 = 2;
                }
                break;
            case CLASS_FUNC_CALL:
            	{
                alt8 = 3;
                }
                break;
            case INSTVAR_FUNC_CALL:
            	{
                alt8 = 4;
                }
                break;
            	default:
            	    NoViableAltException nvae_d8s0 =
            	        new NoViableAltException("", 8, 0, input);

            	    throw nvae_d8s0;
            }

            switch (alt8) 
            {
                case 1 :
                    // YaplTree.g:125:4: ^( FUNC_CALL fn= NAME elist= expr_list )
                    {
                    	Match(input,FUNC_CALL,FOLLOW_FUNC_CALL_in_func_call689); 

                    	Match(input, Token.DOWN, null); 
                    	fn=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_func_call693); 
                    	PushFollow(FOLLOW_expr_list_in_func_call697);
                    	elist = expr_list();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.FunctionCall(fn.Text, elist);

                    }
                    break;
                case 2 :
                    // YaplTree.g:126:4: ^( EXPR_FUNC_CALL fn= NAME elist= expr_list v= variable )
                    {
                    	Match(input,EXPR_FUNC_CALL,FOLLOW_EXPR_FUNC_CALL_in_func_call706); 

                    	Match(input, Token.DOWN, null); 
                    	fn=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_func_call710); 
                    	PushFollow(FOLLOW_expr_list_in_func_call714);
                    	elist = expr_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_variable_in_func_call718);
                    	v = variable();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.FunctionCall(fn.Text, elist, v);

                    }
                    break;
                case 3 :
                    // YaplTree.g:127:4: ^( CLASS_FUNC_CALL fn= NAME elist= expr_list cr= class_reference )
                    {
                    	Match(input,CLASS_FUNC_CALL,FOLLOW_CLASS_FUNC_CALL_in_func_call727); 

                    	Match(input, Token.DOWN, null); 
                    	fn=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_func_call731); 
                    	PushFollow(FOLLOW_expr_list_in_func_call735);
                    	elist = expr_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_class_reference_in_func_call739);
                    	cr = class_reference();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.FunctionCall(fn.Text, elist, cr);

                    }
                    break;
                case 4 :
                    // YaplTree.g:128:4: ^( INSTVAR_FUNC_CALL fn= NAME elist= expr_list inst= instance_variable )
                    {
                    	Match(input,INSTVAR_FUNC_CALL,FOLLOW_INSTVAR_FUNC_CALL_in_func_call748); 

                    	Match(input, Token.DOWN, null); 
                    	fn=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_func_call752); 
                    	PushFollow(FOLLOW_expr_list_in_func_call756);
                    	elist = expr_list();
                    	state.followingStackPointer--;

                    	PushFollow(FOLLOW_instance_variable_in_func_call760);
                    	inst = instance_variable();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 
                    	 result =  Expressions.FunctionCall(fn.Text, elist, inst);

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "func_call"


    // $ANTLR start "return_stmt"
    // YaplTree.g:132:1: return_stmt returns [ReturnExpression result] : ^( RETURN e= expression ) ;
    public ReturnExpression return_stmt() // throws RecognitionException [1]
    {   
        ReturnExpression result = null;

        Expression e = null;


        try 
    	{
            // YaplTree.g:133:2: ( ^( RETURN e= expression ) )
            // YaplTree.g:133:4: ^( RETURN e= expression )
            {
            	Match(input,RETURN,FOLLOW_RETURN_in_return_stmt780); 

            	Match(input, Token.DOWN, null); 
            	PushFollow(FOLLOW_expression_in_return_stmt784);
            	e = expression();
            	state.followingStackPointer--;


            	Match(input, Token.UP, null); 

            				result =  Expressions.ReturnStatement(e);

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "return_stmt"


    // $ANTLR start "expr_list"
    // YaplTree.g:137:1: expr_list returns [List<Expression> list] : ^( EXPR_LIST (v= expression )* ) ;
    public List<Expression> expr_list() // throws RecognitionException [1]
    {   
        List<Expression> list = null;

        Expression v = null;


         list = new List<Expression>(); 
        try 
    	{
            // YaplTree.g:139:2: ( ^( EXPR_LIST (v= expression )* ) )
            // YaplTree.g:139:4: ^( EXPR_LIST (v= expression )* )
            {
            	Match(input,EXPR_LIST,FOLLOW_EXPR_LIST_in_expr_list809); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // YaplTree.g:139:16: (v= expression )*
            	    do 
            	    {
            	        int alt9 = 2;
            	        int LA9_0 = input.LA(1);

            	        if ( ((LA9_0 >= MINUS && LA9_0 <= OR) || (LA9_0 >= STRING_CONSTANT && LA9_0 <= INSTVAR_FUNC_CALL) || LA9_0 == FUNC_CALL || (LA9_0 >= VARIABLE && LA9_0 <= INSTANCE_VARIABLE) || LA9_0 == UNARY) )
            	        {
            	            alt9 = 1;
            	        }


            	        switch (alt9) 
            	    	{
            	    		case 1 :
            	    		    // YaplTree.g:139:17: v= expression
            	    		    {
            	    		    	PushFollow(FOLLOW_expression_in_expr_list814);
            	    		    	v = expression();
            	    		    	state.followingStackPointer--;

            	    		    	 list.Add(v); 

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop9;
            	        }
            	    } while (true);

            	    loop9:
            	    	;	// Stops C# compiler whining that label 'loop9' has no statements


            	    Match(input, Token.UP, null); 
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return list;
    }
    // $ANTLR end "expr_list"


    // $ANTLR start "variable"
    // YaplTree.g:142:1: variable returns [VariableExpression result] : ^( VARIABLE n= NAME ) ;
    public VariableExpression variable() // throws RecognitionException [1]
    {   
        VariableExpression result = null;

        CommonTree n = null;

        try 
    	{
            // YaplTree.g:143:2: ( ^( VARIABLE n= NAME ) )
            // YaplTree.g:143:4: ^( VARIABLE n= NAME )
            {
            	Match(input,VARIABLE,FOLLOW_VARIABLE_in_variable835); 

            	Match(input, Token.DOWN, null); 
            	n=(CommonTree)Match(input,NAME,FOLLOW_NAME_in_variable839); 

            	Match(input, Token.UP, null); 
            	 result =  Expressions.Variable(n.Text); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "variable"


    // $ANTLR start "instance_variable"
    // YaplTree.g:146:1: instance_variable returns [InstanceVariableExpression result] : ^( INSTANCE_VARIABLE n= INSTANCE_NAME ) ;
    public InstanceVariableExpression instance_variable() // throws RecognitionException [1]
    {   
        InstanceVariableExpression result = null;

        CommonTree n = null;

        try 
    	{
            // YaplTree.g:147:2: ( ^( INSTANCE_VARIABLE n= INSTANCE_NAME ) )
            // YaplTree.g:147:4: ^( INSTANCE_VARIABLE n= INSTANCE_NAME )
            {
            	Match(input,INSTANCE_VARIABLE,FOLLOW_INSTANCE_VARIABLE_in_instance_variable858); 

            	Match(input, Token.DOWN, null); 
            	n=(CommonTree)Match(input,INSTANCE_NAME,FOLLOW_INSTANCE_NAME_in_instance_variable862); 

            	Match(input, Token.UP, null); 
            	 result =  Expressions.InstanceVariable(n.Text.Substring(1)); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "instance_variable"


    // $ANTLR start "class_reference"
    // YaplTree.g:150:1: class_reference returns [ClassReferenceExpression result] : ^( CLASS_REFERENCE n= CLASS_NAME ) ;
    public ClassReferenceExpression class_reference() // throws RecognitionException [1]
    {   
        ClassReferenceExpression result = null;

        CommonTree n = null;

        try 
    	{
            // YaplTree.g:151:2: ( ^( CLASS_REFERENCE n= CLASS_NAME ) )
            // YaplTree.g:151:4: ^( CLASS_REFERENCE n= CLASS_NAME )
            {
            	Match(input,CLASS_REFERENCE,FOLLOW_CLASS_REFERENCE_in_class_reference881); 

            	Match(input, Token.DOWN, null); 
            	n=(CommonTree)Match(input,CLASS_NAME,FOLLOW_CLASS_NAME_in_class_reference885); 

            	Match(input, Token.UP, null); 
            	 result =  Expressions.ClassReference(n.Text); 

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "class_reference"


    // $ANTLR start "constant"
    // YaplTree.g:154:1: constant returns [ConstantExpression result] : ( ^( STRING_CONSTANT lit= STRING_LITERAL ) | ^( INT_CONSTANT lit= INTEGER ) | ^( FLOAT_CONSTANT lit= FLOAT ) | ^( BOOL_CONSTANT lit= BOOL_C ) );
    public ConstantExpression constant() // throws RecognitionException [1]
    {   
        ConstantExpression result = null;

        CommonTree lit = null;

        try 
    	{
            // YaplTree.g:155:2: ( ^( STRING_CONSTANT lit= STRING_LITERAL ) | ^( INT_CONSTANT lit= INTEGER ) | ^( FLOAT_CONSTANT lit= FLOAT ) | ^( BOOL_CONSTANT lit= BOOL_C ) )
            int alt10 = 4;
            switch ( input.LA(1) ) 
            {
            case STRING_CONSTANT:
            	{
                alt10 = 1;
                }
                break;
            case INT_CONSTANT:
            	{
                alt10 = 2;
                }
                break;
            case FLOAT_CONSTANT:
            	{
                alt10 = 3;
                }
                break;
            case BOOL_CONSTANT:
            	{
                alt10 = 4;
                }
                break;
            	default:
            	    NoViableAltException nvae_d10s0 =
            	        new NoViableAltException("", 10, 0, input);

            	    throw nvae_d10s0;
            }

            switch (alt10) 
            {
                case 1 :
                    // YaplTree.g:155:4: ^( STRING_CONSTANT lit= STRING_LITERAL )
                    {
                    	Match(input,STRING_CONSTANT,FOLLOW_STRING_CONSTANT_in_constant904); 

                    	Match(input, Token.DOWN, null); 
                    	lit=(CommonTree)Match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_constant910); 

                    	Match(input, Token.UP, null); 

                    			result =  Expressions.StringLiteral(lit.Text.Substring(1, lit.Text.Length - 2));

                    }
                    break;
                case 2 :
                    // YaplTree.g:158:3: ^( INT_CONSTANT lit= INTEGER )
                    {
                    	Match(input,INT_CONSTANT,FOLLOW_INT_CONSTANT_in_constant922); 

                    	Match(input, Token.DOWN, null); 
                    	lit=(CommonTree)Match(input,INTEGER,FOLLOW_INTEGER_in_constant928); 

                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Integer(int.Parse(lit.Text));

                    }
                    break;
                case 3 :
                    // YaplTree.g:161:3: ^( FLOAT_CONSTANT lit= FLOAT )
                    {
                    	Match(input,FLOAT_CONSTANT,FOLLOW_FLOAT_CONSTANT_in_constant940); 

                    	Match(input, Token.DOWN, null); 
                    	lit=(CommonTree)Match(input,FLOAT,FOLLOW_FLOAT_in_constant946); 

                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Float(double.Parse(lit.Text, new NumberFormatInfo()));

                    }
                    break;
                case 4 :
                    // YaplTree.g:164:3: ^( BOOL_CONSTANT lit= BOOL_C )
                    {
                    	Match(input,BOOL_CONSTANT,FOLLOW_BOOL_CONSTANT_in_constant958); 

                    	Match(input, Token.DOWN, null); 
                    	lit=(CommonTree)Match(input,BOOL_C,FOLLOW_BOOL_C_in_constant964); 

                    	Match(input, Token.UP, null); 

                    			result =  Expressions.Boolean(bool.Parse(lit.Text));

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return result;
    }
    // $ANTLR end "constant"

    // Delegated rules


	private void InitializeCyclicDFAs()
	{
	}

 

    public static readonly BitSet FOLLOW_code_block_in_prog61 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_FUNC_DEF_in_function81 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_function85 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000001UL});
    public static readonly BitSet FOLLOW_param_list_in_function89 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_function93 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_VAR_FUNC_DEF_in_function102 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_function106 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000001UL});
    public static readonly BitSet FOLLOW_param_list_in_function110 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_function114 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000004UL});
    public static readonly BitSet FOLLOW_variable_in_function118 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CR_FUNC_DEF_in_function127 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_function131 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000001UL});
    public static readonly BitSet FOLLOW_param_list_in_function135 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_function139 = new BitSet(new ulong[]{0x0080000000000000UL});
    public static readonly BitSet FOLLOW_class_reference_in_function143 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_INSTVAR_FUNC_DEF_in_function152 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_function156 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000001UL});
    public static readonly BitSet FOLLOW_param_list_in_function160 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_function164 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000008UL});
    public static readonly BitSet FOLLOW_instance_variable_in_function168 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_WHILE_ST_in_while_loop187 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_while_loop191 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_while_loop195 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_IF_ST_in_if_statement215 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_if_statement219 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_if_statement223 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_if_statement227 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CLASS_DEF_in_class_def246 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_CLASS_NAME_in_class_def250 = new BitSet(new ulong[]{0x0000800000000000UL});
    public static readonly BitSet FOLLOW_code_block_in_class_def254 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_PARAM_LIST_in_param_list280 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_param_in_param_list285 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000002UL});
    public static readonly BitSet FOLLOW_PARAM_in_param306 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_param310 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CODE_BLOCK_in_code_block340 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_code_block345 = new BitSet(new ulong[]{0x7F7F00001FC00008UL,0x00000000000000FCUL});
    public static readonly BitSet FOLLOW_return_stmt_in_statement368 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_expression_in_statement382 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_assignment_in_statement396 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_function_in_statement410 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_while_loop_in_statement424 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_if_statement_in_statement438 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_class_def_in_statement452 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_set_in_expression473 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression483 = new BitSet(new ulong[]{0x027F00001FC00000UL,0x000000000000002CUL});
    public static readonly BitSet FOLLOW_expression_in_expression487 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_set_in_expression498 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression510 = new BitSet(new ulong[]{0x027F00001FC00000UL,0x000000000000002CUL});
    public static readonly BitSet FOLLOW_expression_in_expression514 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_UNARY_in_expression523 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_unary_operator_in_expression527 = new BitSet(new ulong[]{0x027F00001FC00000UL,0x000000000000002CUL});
    public static readonly BitSet FOLLOW_expression_in_expression531 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_variable_in_expression541 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_instance_variable_in_expression551 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_func_call_in_expression561 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_constant_in_expression571 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ASSIGNMENT_in_assignment589 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_variable_in_assignment593 = new BitSet(new ulong[]{0x027F00001FC00000UL,0x000000000000002CUL});
    public static readonly BitSet FOLLOW_expression_in_assignment597 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ASSIGNMENT_in_assignment606 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_instance_variable_in_assignment610 = new BitSet(new ulong[]{0x027F00001FC00000UL,0x000000000000002CUL});
    public static readonly BitSet FOLLOW_expression_in_assignment614 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_MINUS_in_unary_operator630 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_PLUS_in_unary_operator640 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_DECREMENT_in_unary_operator650 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_INCREMENT_in_unary_operator660 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_NOT_in_unary_operator670 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_FUNC_CALL_in_func_call689 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_func_call693 = new BitSet(new ulong[]{0x8000000000000000UL});
    public static readonly BitSet FOLLOW_expr_list_in_func_call697 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_EXPR_FUNC_CALL_in_func_call706 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_func_call710 = new BitSet(new ulong[]{0x8000000000000000UL});
    public static readonly BitSet FOLLOW_expr_list_in_func_call714 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000004UL});
    public static readonly BitSet FOLLOW_variable_in_func_call718 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CLASS_FUNC_CALL_in_func_call727 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_func_call731 = new BitSet(new ulong[]{0x8000000000000000UL});
    public static readonly BitSet FOLLOW_expr_list_in_func_call735 = new BitSet(new ulong[]{0x0080000000000000UL});
    public static readonly BitSet FOLLOW_class_reference_in_func_call739 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_INSTVAR_FUNC_CALL_in_func_call748 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_func_call752 = new BitSet(new ulong[]{0x8000000000000000UL});
    public static readonly BitSet FOLLOW_expr_list_in_func_call756 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000008UL});
    public static readonly BitSet FOLLOW_instance_variable_in_func_call760 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_RETURN_in_return_stmt780 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_return_stmt784 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_EXPR_LIST_in_expr_list809 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expr_list814 = new BitSet(new ulong[]{0x027F00001FC00008UL,0x000000000000002CUL});
    public static readonly BitSet FOLLOW_VARIABLE_in_variable835 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_NAME_in_variable839 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_INSTANCE_VARIABLE_in_instance_variable858 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_INSTANCE_NAME_in_instance_variable862 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CLASS_REFERENCE_in_class_reference881 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_CLASS_NAME_in_class_reference885 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_STRING_CONSTANT_in_constant904 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_STRING_LITERAL_in_constant910 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_INT_CONSTANT_in_constant922 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_INTEGER_in_constant928 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_FLOAT_CONSTANT_in_constant940 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_FLOAT_in_constant946 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_BOOL_CONSTANT_in_constant958 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_BOOL_C_in_constant964 = new BitSet(new ulong[]{0x0000000000000008UL});

}
}